package org.io4j.filesystem;

import java.util.ArrayList;
import java.util.List;

/**
 * A particular Java platform may support zero or more hierarchically organised
 * file systems. Each file system has a root directory from which all other
 * files in that file system can be reached.
 * 
 * @see java.io.File#listRoots()
 */
public final class FileSystem {

	private FileSystem() {
	}

	/**
	 * Lists the available file system root directory paths.
	 * 
	 * @return {@code List} of {@code Path}s denoting file system root
	 *         directories. List will be empty if there are no file system roots.
	 * @see java.io.File#listRoots()
	 */
	public static List<Path> getRootPaths() {
		List<Path> roots = new ArrayList<Path>();
		for (java.io.File root : java.io.File.listRoots()) {
			roots.add(new Path(root));
		}
		return roots;
	}

	/**
	 * Lists the available file system root directories.
	 * 
	 * @return {@code List} of {@code Directory}s which are file system roots.
	 *         List will be empty if there are no file system roots.
	 * @see java.io.File#listRoots()
	 */
	public static List<Directory> getRootDirectories() {
		List<Directory> roots = new ArrayList<Directory>();
		for (java.io.File root : java.io.File.listRoots()) {
			roots.add(new Directory(root));
		}
		return roots;
	}
}
